package de.baumann.browser.present.duobao

import de.baumann.browser.api.OdinObserver
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.duobao.IDuoBaoSuccessView
import de.baumann.browser.model.checkHash

class DuoBaoSuccessPresenter : BasePresenter<IDuoBaoSuccessView>() {
    fun check(hash: String) {
        checkHash(hash)
                .subscribe(object : OdinObserver<String>(view) {
                    override fun onSuccess(data: String?) {
                        if (data == null) {
                            return
                        }

                        if (data.contains(",")) {
                            view.setCodeList(data.split(","))
                        } else {
                            view.setCodeList(arrayListOf(data))
                        }
                    }
                })
    }
}